package cn.org.mrliu.code.generator.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.ibatis.type.JdbcType;

public class DataTypeUtil {
	static Map<String, String> javaTypeMap = new HashMap<>();
	static Map<String, JdbcType> jdbcTypeMap = new HashMap<>();
	static{
		javaTypeMap.put("bigint", "Long");
		javaTypeMap.put("varchar", "String");
		javaTypeMap.put("int", "Integer");
		javaTypeMap.put("float", "Double");
		javaTypeMap.put("date", "Date");
		javaTypeMap.put("datetime", "Date");
		javaTypeMap.put("timestamp", "Date");
		
		jdbcTypeMap.put("bigint", JdbcType.BIGINT);
		jdbcTypeMap.put("varchar", JdbcType.VARCHAR);
		jdbcTypeMap.put("int", JdbcType.INTEGER);
		jdbcTypeMap.put("float", JdbcType.DOUBLE);
		jdbcTypeMap.put("date", JdbcType.DATE);
		jdbcTypeMap.put("datetime", JdbcType.TIMESTAMP);
		jdbcTypeMap.put("timestamp", JdbcType.TIMESTAMP);
	}
	
	public static String getJavaTypeName(String name) {
		return javaTypeMap.get(name);
	}
	
	public static JdbcType getJdbcType(String name) {
		return jdbcTypeMap.get(name);
	}
	
	public static String getJdbcTypeName(String name) {
		return getJdbcType(name).toString();
	}
	
}
